package com.code.monitor.service.impl;

import com.code.monitor.conditions.MysqlRuntimeCondition;
import com.code.monitor.mapper.PackageInfoMapper;
import com.code.monitor.model.PackageInfo;
import com.code.monitor.service.PackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Service;

import java.util.Collection;

@Conditional(MysqlRuntimeCondition.class)
@Service
public class MysqlPackageServiceImpl implements PackageService {
    @Autowired
    private PackageInfoMapper packageInfoMapper;

    @Override
    public void addPackage(PackageInfo packageInfo) {
        packageInfoMapper.insert(packageInfo);
    }

    @Override
    public void delPackage(String uuid) {
        packageInfoMapper.deleteByUUID(uuid);
    }

    @Override
    public Collection<PackageInfo> queryAllPackage() {
        return packageInfoMapper.queryAll();
    }

    @Override
    public PackageInfo queryPackageByUUID(String uuid) {
        return packageInfoMapper.queryByUUID(uuid);
    }
}
